package com.dgshanger.sanhxiaofeisc.ui.person

import android.support.v4.content.ContextCompat
import android.widget.TextView
import com.dgshanger.sanhxiaofeisc.R
import com.xx.baseuilibrary.mvp.BaseMvpViewActivity
import kotlinx.android.synthetic.main.activity_promote_ranking.*


/**
 * PromoteRankingActivity
 * 沉迷学习不能自拔
 * Describe：推广排行榜
 * Created by 雷小星🍀 on 2018/4/16 14:44.
 */
class PromoteRankingActivity : BaseMvpViewActivity() {


    companion object {
        val TYPE_DAY = "day"
        val TYPE_WEEK = "week"
        val TYPE_MONTH = "month"
    }

    override fun getActivityLayoutId(): Int = R.layout.activity_promote_ranking
    private lateinit var titleList: ArrayList<TextView>

    private lateinit var promoteRankingListFragment: PromoteRankingListFragment
    override fun initData() {
        titleList = arrayListOf(tv_month, tv_week, tv_minute)
        promoteRankingListFragment = supportFragmentManager.findFragmentById(R.id.fragment_promote_ranking) as PromoteRankingListFragment
    }

    private fun selectTitle(type: Int) {
        for (i in titleList.indices) {
            titleList[i].textSize = if (type == i) 28f else 18f
            titleList[i].setTextColor(ContextCompat.getColor(mContext, if (type == i) R.color.colorBlack else R.color.colorText))
        }
    }

    override fun initEvent() {
        tv_month.setOnClickListener {
            selectTitle(0)
            promoteRankingListFragment.type = TYPE_MONTH
        }
        tv_week.setOnClickListener {
            selectTitle(1)
            promoteRankingListFragment.type = TYPE_WEEK
        }
        tv_minute.setOnClickListener {
            selectTitle(2)
            promoteRankingListFragment.type = TYPE_DAY
        }

        tv_month.performClick()
    }
}